<!Doctype html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<meta name="viewport" content="width=device-width, initial-scale=1.0" />
	<title>2.4 Verilog 表达式 | 菜鸟教程</title>

  <meta name='robots' content='max-image-preview:large' />
<link rel='stylesheet' id='classic-theme-styles-css' href='../0/classic-themes.min.css?ver=6.2' type='text/css' media='all' />
<link rel="canonical" href="../w3cnote/verilog-expression.html" />
<meta name="keywords" content="2.4 Verilog 表达式">
<meta name="description" content="表达式 表达式由操作符和操作数构成，其目的是根据操作符的意义得到一个计算结果。表达式可以在出现数值的任何地方使用。例如：  实例 [mycode4 type=&#039;verilog&#039;] a^b ;          //a与b进行异或操作 address[9:0] + 10&#039;b1 ;  //地址累加 flag1 &amp;&amp; flag2 ;  //逻辑与操作 [/mycode4] 操作数 操作数可以是任意..">
		
	<link rel="shortcut icon" href="https://static.runoob.com/images/favicon.ico">
	<link rel="stylesheet" href="../0/style.css?v=1.170" type="text/css" media="all" />	
	<link rel="stylesheet" href="../0/font-awesome.min.css" media="all" />	
  <!--[if gte IE 9]><!-->
  <script src=""></script>
  <!--<![endif]-->
  <!--[if lt IE 9]>
     <script src=""></script>
     <script src=""></script>
  <![endif]-->
  <link rel="apple-touch-icon" href="https://static.runoob.com/images/icon/mobile-icon.png"/>
  <meta name="apple-mobile-web-app-title" content="菜鸟教程">
</head>
<body>

<!--  头部 -->
<div class="container logo-search">

  <div class="col search row-search-mobile">
    <form action="index.php">
      <input class="placeholder" placeholder="搜索……" name="s" autocomplete="off">
      
    </form>
  </div>

  <div class="row">
    <div class="col logo">
      <h1><a href="../">菜鸟教程 -- 学的不仅是技术，更是梦想！</a></h1>
    </div>
        <div class="col right-list"> 
    <button class="btn btn-responsive-nav btn-inverse" data-toggle="collapse" data-target=".nav-main-collapse" id="pull" style=""> <i class="fa fa-navicon"></i> </button>
    </div>
        
    <div class="col search search-desktop last">
      <div class="search-input" >
      <form action="//www.runoob.com/" target="_blank">
        <input class="placeholder" id="s" name="s" placeholder="搜索……"  autocomplete="off" style="height: 44px;">
      </form>
      
      </div>
    </div>
  </div>
</div>



<!-- 导航栏 -->
<div class="container navigation">
    <div class="row">
        <div class="col nav">
            

                        <ul class="pc-nav" id="note-nav">
                <li><a href="../">首页</a></li>
                <li><a href="../w3cnote">笔记首页</a></li>
                <li><a href="../w3cnote/android-tutorial-intro.html" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" title="ES6 教程">ES6 教程</a></li>
                <li><a href="../w3cnote/ten-sorting-algorithm.html" title="排序算法">排序算法</a></li>
                <li><a href="../w3cnote/hadoop-tutorial.html" title="Hadoop 教程">Hadoop</a></li>
                <li><a href="../w3cnote/zookeeper-tutorial.html" title="Zookeeper 教程">Zookeeper</a></li>
                <li><a href="../w3cnote/verilog-tutorial.html" title="Verilog 教程">Verilog</a></li>
                <li><a href="../w3cnote_genre/code" title="编程技术">编程技术</a></li> 
                <li><a href="../w3cnote_genre/coderlife" title="程序员人生">程序员人生</a></li>
                
                <!--<li><a href="javascript:;" class="runoob-pop">登录</a></li>
                
                
                        <li>
                <a style="font-weight:bold;" href="../linux/linux-tutorial.html#yunserver" target="_blank" onclick="_hmt.push(['_trackEvent', 'aliyun', 'click', 'aliyun'])" title="kkb">云服务器</a>
                </li>
                <li><a href="http://gk.link/a/104mQ" target="_blank" style="font-weight: bold;"onclick="_hmt.push(['_trackEvent', '极客时间', 'click', 'jike'])" title="我的圈子">极客时间</a></li>
            
                
                <li><a target="_blank" href="../shoppinglist" rel="nofollow">知识店铺</a></li> 
        -->
            </ul>
                        
              
            <ul class="mobile-nav">
                <li><a href="../w3cnote">首页</a></li>
                <li><a href="../w3cnote_genre/android" target="_blank" title="Android 基础入门教程">Android</a></li>
                <li><a href="../w3cnote/es6-tutorial.html" target="_blank" title="ES6 教程">ES6</a></li>
                <li><a href="../w3cnote_genre/joke" target="_blank" title="程序员笑话">逗乐</a></li>
                
                <a href="javascript:void(0)" class="search-reveal">Search</a> 
            </ul>
            
        </div>
    </div>
</div>


<!--  内容  -->
<div class="container main">
	<div class="row">

		<!--  Android 基础入门教程 start  -->
	<div class="col left-column" style="display:none;">
		<div class="tab">Verilog 教程</div>
		<div class="sidebar-box gallery-list">
			<div class="design" id="leftcolumn">  
			</div> 
		</div> 
	</div>
	<!--  Android 基础入门教程 end  -->
		<div class="col middle-column big-middle-column">
	 			<div class="article">
			<div class="article-heading">
				<h2>2.4 Verilog 表达式</h2>				<h3><em>分类</em> <a href="../w3cnote_genre/verilog" title="Verilog 教程" >Verilog 教程</a> </h3>
			</div>
			<div class="article-body note-body">
				<div class="article-intro">
					<h3>表达式</h3><p>
表达式由操作符和操作数构成，其目的是根据操作符的意义得到一个计算结果。表达式可以在出现数值的任何地方使用。例如：</p>

<div class="example"><h2 class="example">实例</h2> <div class="example_code">
a<span style="color: #5D478B;">^</span>b <span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//a与b进行异或操作</span><br />
address<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">9</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span><span style="color: #ff0055;">0'b1</span> <span style="color: #5D478B;">;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//地址累加</span><br />
flag1 <span style="color: #5D478B;">&amp;&amp;</span> flag2 <span style="color: #5D478B;">;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//逻辑与操作</span><br />
</div></div>
<h3>操作数</h3><p>
操作数可以是任意的数据类型，只是某些特定的语法结构要求使用特定类型的操作数。</p>
<p>操作数可以为常数，整数，实数，线网，寄存器，时间，位选，域选，存储器及函数调用等。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: #A52A2A; font-weight: bold;">module</span> test<span style="color: #5D478B;">;</span><br />
<br />
<span style="color: #00008B; font-style: italic;">//实数</span><br />
<span style="color: #A52A2A; font-weight: bold;">real</span> a<span style="color: #5D478B;">,</span> b<span style="color: #5D478B;">,</span> c<span style="color: #5D478B;">;</span><br />
c <span style="color: #5D478B;">=</span> a <span style="color: #5D478B;">+</span> b <span style="color: #5D478B;">;</span><br />
<br />
<span style="color: #00008B; font-style: italic;">//寄存器</span><br />
<span style="color: #A52A2A; font-weight: bold;">reg</span> &nbsp;<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; cprmu_1<span style="color: #5D478B;">,</span> cprmu_2 <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">always</span> <span style="color: #5D478B;">@</span><span style="color: #9F79EE;">&#40;</span><span style="color: #A52A2A; font-weight: bold;">posedge</span> clk<span style="color: #9F79EE;">&#41;</span> <span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; cprmu_2 <span style="color: #5D478B;">=</span> cprmu_1 <span style="color: #5D478B;">^</span> cprmu_2 <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">end</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<br />
<span style="color: #00008B; font-style: italic;">//函数</span><br />
<span style="color: #A52A2A; font-weight: bold;">reg</span> &nbsp;flag1 <span style="color: #5D478B;">;</span><br />
flag <span style="color: #5D478B;">=</span> calculate_result<span style="color: #9F79EE;">&#40;</span>A<span style="color: #5D478B;">,</span> B<span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span><br />
&nbsp;<br />
<span style="color: #00008B; font-style: italic;">//非法操作数</span><br />
<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp; res<span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">wire</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;temp<span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">always</span><span style="color: #5D478B;">@</span> （<span style="color: #5D478B;">*</span>）<span style="color: #A52A2A; font-weight: bold;">begin</span><br />
&nbsp; &nbsp; res &nbsp; &nbsp;<span style="color: #5D478B;">=</span> cprmu_2 – cprmu_1 <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//temp = cprmu_2 – cprmu_1 ; //不合法，always块里赋值对象不能是wire型</span><br />
<span style="color: #A52A2A; font-weight: bold;">end</span><br />
<br />
<span style="color: #A52A2A; font-weight: bold;">endmodule</span><br />
</div></div>
<h3>操作符</h3>
<p>Verilog 中提供了大约 9 种操作符，分别是算术、关系、等价、逻辑、按位、归约、移位、拼接、条件操作符。</p>

<p>大部分操作符与 C 语言中类似。同类型操作符之间，除条件操作符从右往左关联，其余操作符都是自左向右关联。圆括号内表达式优先执行。例如下面每组的 2 种写法都是等价的。</p>

<pre>
//自右向左关联，两种写法等价
A+B-C ;
(A+B）-C ;

//自右向左关联，两种写法等价，结果为 B、D 或 F
A ? B : C ? D : F ;
A ? B : (C ? D : F) ;

//自右向左关联，两种写法不等价
(A ? B : C) ? D : F ;  //结果 D 或 F
A ? B : C ? D : F ; //结果为 B、D 或 F
</pre>
<p>不同操作符之间，优先级是不同的。下表列出了操作符优先级从高至低的排列顺序。当没有圆括号时，Verilog 会根据操作符优先级对表达式进行计算。为了避免由操作符优先级导致的计算混乱，在不确定优先级时，建议用圆括号将表达式区分开来。</p>
<table class="reference"><thead><tr><th style="text-align:left;"><span>操作符</span></th><th style="text-align:left;"><span>操作符号</span></th><th style="text-align:left;"><span>优先级</span></th></tr></thead><tbody><tr><td style="text-align:left;"><span>单目运算</span></td><td style="text-align:left;"><span>+ - ! ~</span></td><td style="text-align:left;"><span>最高</span></td></tr><tr><td style="text-align:left;"><span>乘、除、取模</span></td><td style="text-align:left;"><span>* / %</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>加减</span></td><td style="text-align:left;"><span>+ -</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>移位</span></td><td style="text-align:left;"><span>&lt;&lt; &nbsp;&gt;&gt;</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>关系</span></td><td style="text-align:left;"><span>&lt;&nbsp;   &lt;=&nbsp; &gt;&nbsp; &gt;=</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>等价</span></td><td style="text-align:left;"><span>==&nbsp;   !=&nbsp; ===&nbsp; !===</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>归约</span></td><td style="text-align:left;"><span>&amp; ~&amp;</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>^ ~^</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>|</span><span>  ~</span><span>|</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>逻辑</span></td><td style="text-align:left;"><span>&amp;&amp;</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>|</span><span>|</span></td><td style="text-align:left;">&nbsp;</td></tr><tr><td style="text-align:left;"><span>条件</span></td><td style="text-align:left;"><span>?:</span></td><td style="text-align:left;"><span>最低</span></td></tr></tbody></table>

<h3>算术操作符</h3><p>
算术操作符包括单目操作符和双目操作符。</p>
<p>
双目操作符对 2 个操作数进行算术运算，包括乘（*）、除（/）、加（+）、减（-）、求幂（**）、取模（%）。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp;a<span style="color: #5D478B;">,</span> b<span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">4</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp;c <span style="color: #5D478B;">;</span><br />
a <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b0010</span> <span style="color: #5D478B;">;</span><br />
b <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b1001</span> <span style="color: #5D478B;">;</span><br />
c <span style="color: #5D478B;">=</span> a<span style="color: #5D478B;">+</span>b<span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//结果为c=b'b1011</span><br />
c <span style="color: #5D478B;">=</span> a<span style="color: #5D478B;">/</span>b<span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//结果为c=4，取整</span><br />
</div></div>
<p>如果操作数某一位为 X，则计算结果也会全部出现 X。例如：</p>

<div class="example"><h2 class="example">实例</h2> <div class="example_code">
b <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b100x</span> <span style="color: #5D478B;">;</span><br />
c <span style="color: #5D478B;">=</span> a<span style="color: #5D478B;">+</span>b <span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//结果为c=4'bxxxx</span><br />
</div></div>
<p>对变量进行声明时，要根据变量的操作符对变量的位宽进行合理声明，不要让结果溢出。上述例子中，相加的 2 个变量位宽为 4bit，那么结果寄存器变量位宽最少为 5bit。否则，高位将被截断，导致结果高位丢失。无符号数乘法时，结果变量位宽应该为 2 个操作数位宽之和。</p>

<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;mula <span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">1</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;mulb<span style="color: #5D478B;">;</span><br />
<span style="color: #A52A2A; font-weight: bold;">reg</span> <span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">5</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span> &nbsp; &nbsp; &nbsp; &nbsp;res <span style="color: #5D478B;">;</span><br />
mula <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'he</span> &nbsp; <span style="color: #5D478B;">;</span><br />
mulb <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2'h3</span> &nbsp; <span style="color: #5D478B;">;</span><br />
res &nbsp;<span style="color: #5D478B;">=</span> mula <span style="color: #5D478B;">*</span> mulb <span style="color: #5D478B;">;</span> <span style="color: #00008B; font-style: italic;">//结果为res=6'h2a, 数据结果没有丢失位数</span><br />
</div></div><p>
+ 和 - 也可以作为单目操作符来使用，表示操作数的正负性。此类操作符优先级最高。</p>

<pre>-4  //表示负4
+3  //表示正3</pre>
<p>负数表示时，可以直接在十进制数字前面增加一个减号 <span class="marked">-</span>，也可以指定位宽。因为负数使用二进制补码来表示，不指定位宽来表示负数，编译器在转换时，会自动分配位宽，从而导致意想不到的结果。例如：</p>

<div class="example"><h2 class="example">实例</h2> <div class="example_code">
mula <span style="color: #5D478B;">=</span> <span style="color: #5D478B;">-</span><span style="color: #ff0055;">4'd4</span> <span style="color: #5D478B;">;</span><br />
mulb <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2</span> <span style="color: #5D478B;">;</span><br />
res <span style="color: #5D478B;">=</span> mula <span style="color: #5D478B;">*</span> mulb <span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//计算结果为res=-6'd8, 即res=6'h38，正常</span><br />
res <span style="color: #5D478B;">=</span> mula <span style="color: #5D478B;">*</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">-</span>'d4<span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">;</span> &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//(4的32次幂-4) * 2, 结果异常 </span><br />
</div></div>

<h3>关系操作符</h3>
<p>关系操作符有大于（&gt;），小于（&lt;），大于等于（&gt;=），小于等于（&lt;=）。</p>
<p>关系操作符的正常结果有 2 种，真（1）或假（0）。</p>
<p>如果操作数中有一位为 x 或 z，则关系表达式的结果为 x。</p>


<div class="example"><h2 class="example">实例</h2> <div class="example_code">
A <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4</span> <span style="color: #5D478B;">;</span><br />
B <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">3</span> <span style="color: #5D478B;">;</span><br />
X <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">3'b1xx</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <br />
A <span style="color: #5D478B;">&gt;</span> B &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//为真</span><br />
A <span style="color: #5D478B;">&lt;=</span> B &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//为假</span><br />
A <span style="color: #5D478B;">&gt;=</span> Z &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//为X，不确定</span><br />
</div></div>

<h3>等价操作符</h3><p>
等价操作符包括逻辑相等（==），逻辑不等（!=），全等（===），非全等（!==）。</p><p>
等价操作符的正常结果有 2 种：为真（1）或假（0）。</p><p>
逻辑相等/不等操作符不能比较 x 或 z，当操作数包含一个 x 或 z，则结果为不确定值。</p><p>
全等比较时，如果按位比较有相同的 x 或 z，返回结果也可以为 1，即全等比较可比较 x 或 z。所以，全等比较的结果一定不包含 x。举例如下：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
A <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4</span> <span style="color: #5D478B;">;</span><br />
B <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">8'h04</span> <span style="color: #5D478B;">;</span><br />
C <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'bxxxx</span> <span style="color: #5D478B;">;</span><br />
D <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'hx</span> <span style="color: #5D478B;">;</span><br />
A <span style="color: #5D478B;">==</span> B &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//为真</span><br />
A <span style="color: #5D478B;">==</span> <span style="color: #9F79EE;">&#40;</span>B <span style="color: #5D478B;">+</span> <span style="color: #ff0055;">1</span><span style="color: #9F79EE;">&#41;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//为假</span><br />
A <span style="color: #5D478B;">==</span> C &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//为X，不确定</span><br />
A <span style="color: #5D478B;">===</span> C &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//为假，返回值为0</span><br />
C <span style="color: #5D478B;">===</span> D &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//为真，返回值为1 </span><br />
</div></div>

<h3>逻辑操作符</h3>
<p>
逻辑操作符主要有 3 个：&&（逻辑与）, ||（逻辑或），!（逻辑非）。</p><p>
逻辑操作符的计算结果是一个 1bit 的值，0 表示假，1 表示真，x 表示不确定。</p><p>
如果一个操作数不为 0，它等价于逻辑 1；如果一个操作数等于 0，它等价于逻辑 0。如果它任意一位为 x 或 z，它等价于 x。</p><p>
如果任意一个操作数包含 x，逻辑操作符运算结果不一定为 x。</p><p>
逻辑操作符的操作数可以为变量，也可以为表达式。例如：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
A <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">3</span><span style="color: #5D478B;">;</span> <br />
B <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">0</span><span style="color: #5D478B;">;</span> <br />
C <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">2'b1x</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <br />
A <span style="color: #5D478B;">&amp;&amp;</span> B &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">// &nbsp; &nbsp; 为假</span><br />
A <span style="color: #5D478B;">||</span> B &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">// &nbsp; &nbsp; 为真</span><br />
<span style="color: #5D478B;">!</span> A &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">// &nbsp; &nbsp; 为假</span><br />
<span style="color: #5D478B;">!</span> B &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">// &nbsp; &nbsp; 为真</span><br />
A <span style="color: #5D478B;">&amp;&amp;</span> C &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">// &nbsp; &nbsp; 为X，不确定</span><br />
A <span style="color: #5D478B;">||</span> C &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">// &nbsp; &nbsp; 为真，因为A为真</span><br />
<span style="color: #9F79EE;">&#40;</span>A<span style="color: #5D478B;">==</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">&amp;&amp;</span> <span style="color: #9F79EE;">&#40;</span><span style="color: #5D478B;">!</span> B<span style="color: #9F79EE;">&#41;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//为真，此时第一个操作数为表达式</span><br />
</div></div>

<h3>按位操作符</h3>
<p>
按位操作符包括：取反（~），与（&），或（|），异或（^），同或（~^）。</p><p>
按位操作符对 2 个操作数的每 1bit 数据进行按位操作。</p><p>
如果 2 个操作数位宽不相等，则用 0 向左扩展补充较短的操作数。</p><p>
取反操作符只有一个操作数，它对操作数的每 1bit 数据进行取反操作。</p>
<p>
下图给出了按位操作符的逻辑规则。</p>

<table class="reference"><thead><tr><th style="text-align:left;"><span>&amp;(与）</span></th><th style="text-align:left;"><span>0</span></th><th style="text-align:left;"><span>1</span></th><th style="text-align:left;"><span>x</span></th><th style="text-align:left;">&nbsp;</th><th style="text-align:left;"><span>|</span><span>(或)</span></th><th style="text-align:left;"><span>0</span></th><th style="text-align:left;"><span>1</span></th><th style="text-align:left;"><span>x</span></th></tr></thead><tbody><tr><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>x</span></td></tr><tr><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>1</span></td></tr><tr><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>x</span></td></tr></tbody></table>

<table class="reference"><thead><tr><th style="text-align:left;"><span>^(异或)</span></th><th style="text-align:left;"><span>0</span></th><th style="text-align:left;"><span>1</span></th><th style="text-align:left;"><span>x</span></th><th style="text-align:left;">&nbsp;</th><th style="text-align:left;"><span>~^(同或)</span></th><th style="text-align:left;"><span>0</span></th><th style="text-align:left;"><span>1</span></th><th style="text-align:left;"><span>x</span></th></tr></thead><tbody><tr><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>x</span></td></tr><tr><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>0</span></td><td style="text-align:left;"><span>1</span></td><td style="text-align:left;"><span>x</span></td></tr><tr><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;">&nbsp;</td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td><td style="text-align:left;"><span>x</span></td></tr></tbody></table>

<div class="example"><h2 class="example">实例</h2> <div class="example_code">
A <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b0101</span> <span style="color: #5D478B;">;</span><br />
B <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b1001</span> <span style="color: #5D478B;">;</span><br />
C <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'bx010</span> <span style="color: #5D478B;">;</span><br />
&nbsp; &nbsp; <br />
<span style="color: #5D478B;">~</span>A &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//4'b1010</span><br />
A <span style="color: #5D478B;">&amp;</span> B &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//4'b0001</span><br />
A <span style="color: #5D478B;">|</span> B &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//4'b1101</span><br />
A<span style="color: #5D478B;">^</span>B &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//4'b1100</span><br />
A <span style="color: #5D478B;">~^</span> B &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//4'b0011</span><br />
B <span style="color: #5D478B;">|</span> C &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//4'b1011</span><br />
B<span style="color: #5D478B;">&amp;</span>C &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//4'bx000</span><br />
</div></div>

<h3>归约操作符</h3><p>
归约操作符包括：归约与（&），归约与非（~&），归约或（|），归约或非（~|），归约异或（^），归约同或（~^）。</p><p>
归约操作符只有一个操作数，它对这个向量操作数逐位进行操作，最终产生一个 1bit 结果。</p><p>逻辑操作符、按位操作符和归约操作符都使用相同的符号表示，因此有时候容易混淆。区分这些操作符的关键是分清操作数的数目，和计算结果的规则。</p>
    
<pre>
A = 4'b1010 ;
&amp;A ;      //结果为 1 &amp; 0 &amp; 1 &amp; 0 = 1'b0，可用来判断变量A是否全1
~|A ;     //结果为 ~(1 | 0 | 1 | 0) = 1'b0, 可用来判断变量A是否为全0
^A ;      //结果为 1 ^ 0 ^ 1 ^ 0 = 1'b0
</pre>


<h3>移位操作符</h3><p>
移位操作符包括左移（&lt;&lt;），右移（&gt;&gt;），算术左移（&lt;&lt;&lt;），算术右移（&gt;&gt;&gt;）。</p>
<p>移位操作符是双目操作符，两个操作数分别表示要进行移位的向量信号（操作符左侧）与移动的位数（操作符右侧）。</p>
<p>算术左移和逻辑左移时，右边低位会补 0。</p><p>
逻辑右移时，左边高位会补 0；而算术右移时，左边高位会补充符号位，以保证数据缩小后值的正确性。</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
A <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b1100</span> <span style="color: #5D478B;">;</span><br />
B <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b0010</span> <span style="color: #5D478B;">;</span><br />
A <span style="color: #5D478B;">=</span> A <span style="color: #5D478B;">&gt;&gt;</span> <span style="color: #ff0055;">2</span> <span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//结果为 4'b0011</span><br />
A <span style="color: #5D478B;">=</span> A <span style="color: #5D478B;">&lt;&lt;</span> <span style="color: #ff0055;">1</span><span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//结果为 4'b1000</span><br />
A <span style="color: #5D478B;">=</span> A <span style="color: #5D478B;">&lt;&lt;&lt;</span> <span style="color: #ff0055;">1</span> <span style="color: #5D478B;">;</span> &nbsp; &nbsp; &nbsp; <span style="color: #00008B; font-style: italic;">//结果为 4'b1000</span><br />
C <span style="color: #5D478B;">=</span> B <span style="color: #5D478B;">+</span> <span style="color: #9F79EE;">&#40;</span>A<span style="color: #5D478B;">&gt;&gt;&gt;</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#41;</span><span style="color: #5D478B;">;</span> &nbsp; &nbsp;<span style="color: #00008B; font-style: italic;">//结果为 2 + (-4/4) = 1, 4'b0001</span><br />
</div></div>
<h3>拼接操作符</h3><p>拼接操作符用大括号 <span class="marked">{，}</span> 来表示，用于将多个操作数（向量）拼接成新的操作数（向量），信号间用逗号隔开。</p>
<p>拼接符操作数必须指定位宽，常数的话也需要指定位宽。例如：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
A <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">4'b1010</span> <span style="color: #5D478B;">;</span><br />
B <span style="color: #5D478B;">=</span> <span style="color: #ff0055;">1'b1</span> <span style="color: #5D478B;">;</span><br />
Y1 <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span>B<span style="color: #5D478B;">,</span> A<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">3</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">2</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> A<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">0</span><span style="color: #9F79EE;">&#93;</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">4'h3</span> <span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//结果为Y1='b1100_0011</span><br />
Y2 <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span><span style="color: #ff0055;">4</span><span style="color: #9F79EE;">&#123;</span>B<span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">,</span> <span style="color: #ff0055;">3'd4</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//结果为 Y2=7'b111_1100</span><br />
Y3 <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#123;</span><span style="color: #ff0055;">32</span><span style="color: #9F79EE;">&#123;</span><span style="color: #ff0055;">1'b0</span><span style="color: #9F79EE;">&#125;</span><span style="color: #9F79EE;">&#125;</span><span style="color: #5D478B;">;</span> &nbsp;<span style="color: #00008B; font-style: italic;">//结果为 Y3=32h0，常用作寄存器初始化时匹配位宽的赋初值</span><br />
</div></div>

<h3>条件操作符</h3>
<p>条件表达式有 3 个操作符，结构描述如下：</p>
<pre>condition_expression ? true_expression : false_expression</pre>
<p>计算时，如果 condition_expression 为真（逻辑值为 1），则运算结果为 true_expression；如果 condition_expression 为假（逻辑值为 0），则计算结果为 false_expression。</p>
<pre>assign hsel    = (addr[9:8] == 2'b0) ? hsel_p1 : hsel_p2 ;
//当信号 addr 高 2bit 为 0 时，hsel 赋值为 hsel_p1; 否则，将 hsel_p2 赋值给 hsel。
</pre>
<p>其实，条件表达式类似于 2 路（或多路）选择器，其描述方式完全可以用 if-else 语句代替。
</p>
<p>当然条件操作符也能进行嵌套，完成一个多次选择的逻辑。例如：</p>
<div class="example"><h2 class="example">实例</h2> <div class="example_code">
<span style="color: #A52A2A; font-weight: bold;">assign</span> &nbsp; hsel <span style="color: #5D478B;">=</span> <span style="color: #9F79EE;">&#40;</span>addr<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">9</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">==</span> <span style="color: #ff0055;">2'b00</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> hsel_p1 <span style="color: #5D478B;">:</span> <br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>addr<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">9</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">==</span> <span style="color: #ff0055;">2'b01</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> hsel_p2 <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>addr<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">9</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">==</span> <span style="color: #ff0055;">2'b10</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> hsel_p3 <span style="color: #5D478B;">:</span><br />
&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; <span style="color: #9F79EE;">&#40;</span>addr<span style="color: #9F79EE;">&#91;</span><span style="color: #ff0055;">9</span><span style="color: #5D478B;">:</span><span style="color: #ff0055;">8</span><span style="color: #9F79EE;">&#93;</span> <span style="color: #5D478B;">==</span> <span style="color: #ff0055;">2'b11</span><span style="color: #9F79EE;">&#41;</span> <span style="color: #5D478B;">?</span> hsel_p4 <span style="color: #5D478B;">;</span><br />
</div></div>				</div>
			</div>
			<div class="previous-next-links">
			<div class="previous-design-link">← <a href="../w3cnote/verilog-data-type.html" rel="prev"> 2.3 Verilog 数据类型</a> </div>
			<div class="next-design-link"><a href="../w3cnote/verilog-assign.html" rel="next"> 3.1 Verilog 连续赋值</a> →</div>
			</div>
						<div class="article-heading-ad" id="w3cnote-ad728">
			<script async src=""></script>
			<!-- 移动版 自动调整 -->
			<ins class="adsbygoogle"
			     style="display:inline-block;min-width:300px;max-width:970px;width:100%;height:90px"
			     data-ad-client="ca-pub-5751451760833794"
			     data-ad-slot="1691338467"
			     data-ad-format="horizontal"></ins>
			<script>
			(adsbygoogle = window.adsbygoogle || []).push({});
			</script>
			</div>
			<style>
@media screen and (max-width: 768px) {
	#w3cnote-ad728 {
		display: none;
	}
}
p.note-author {
    border-bottom: 1px solid #ddd;
    font-size: 18px;
    font-weight: bold;
    color: #78a15a;
    padding-bottom: 2px;
    margin-bottom: 4px;
}
</style>
<script>
var aid = 22872;
</script>
	</div>
		
	</div>
	<div class="listcol last right-column">

	<script type="text/javascript">
jQuery(document).ready(function ($){
	var total = $(".membership li").length;
	var left_list = '';
	href = window.location.href;
	
	$(".membership li").each(function(index, value){

		left_list += $(this).html();

		cur_href = $(this).find("a").attr("href");
		cur_obj = $(this);
		
		if(href.match(cur_href) != null) {
			if(index==0) {
				$(".previous-design-link").hide();
			}
			if(index==(total-1)) {
				$(".next-design-link").hide();
			}
			prev_href = cur_obj.prev("li").find("a").attr("href");
			prev_title = cur_obj.prev("li").find("a").attr("title");

			next_href = cur_obj.next("li").find("a").attr("href");
			next_title = cur_obj.next("li").find("a").attr("title");
			if(prev_title) {
				$(".previous-design-link a").attr("href", prev_href);
				$(".previous-design-link a").attr("title", prev_title);
				$(".previous-design-link a").text(prev_title);
			} else {
				$(".previous-design-link").html("");
			}

			if(next_title) {
				$(".next-design-link a").attr("href", next_href);
				$(".next-design-link a").attr("title", next_title);
				$(".next-design-link a").text(next_title);
			} else {
				$(".next-design-link").html("");
			}
		}
	});

	$("#leftcolumn").html(left_list);
});
	</script>
	<div class="sidebar-box cate-list">
	<div class="sidebar-box recommend-here list-link">
	<a href="javascript:void(0);">Verilog 教程</a>	</div>
	
	<ul class="membership">
		
	<li><a target="_top" data-id="22850" title="1.1 Verilog 教程" href="../w3cnote/verilog-tutorial.html" >1.1 Verilog 教程</a></li>
	
		
	<li><a target="_top" data-id="22851" title="1.2 Verilog 简介" href="../w3cnote/verilog-intro.html" >1.2 Verilog 简介</a></li>
	
		
	<li><a target="_top" data-id="22852" title="1.3 Verilog 环境搭建" href="../w3cnote/verilog-install.html" >1.3 Verilog 环境搭建</a></li>
	
		
	<li><a target="_top" data-id="22866" title="1.4 Verilog 设计方法" href="../w3cnote/verilog-design-method.html" >1.4 Verilog 设计方法</a></li>
	
		
	<li><a target="_top" data-id="22869" title="2.1 Verilog 基础语法" href="../w3cnote/verilog-basic-syntax.html" >2.1 Verilog 基础语法</a></li>
	
		
	<li><a target="_top" data-id="22870" title="2.2 Verilog 数值表示" href="../w3cnote/verilog-number.html" >2.2 Verilog 数值表示</a></li>
	
		
	<li><a target="_top" data-id="22871" title="2.3 Verilog 数据类型" href="../w3cnote/verilog-data-type.html" >2.3 Verilog 数据类型</a></li>
	
		<li>
	2.4 Verilog 表达式	</li>
	
		
	<li><a target="_top" data-id="22935" title="2.5 Verilog 编译指令" href="../w3cnote/verilog-compile-instruction.html" >2.5 Verilog 编译指令</a></li>
	
		
	<li><a target="_top" data-id="22931" title="3.1 Verilog 连续赋值" href="../w3cnote/verilog-assign.html" >3.1 Verilog 连续赋值</a></li>
	
		
	<li><a target="_top" data-id="22933" title="3.2 Verilog 时延" href="../w3cnote/verilog-time-delay.html" >3.2 Verilog 时延</a></li>
	
		
	<li><a target="_top" data-id="22936" title="4.1 Verilog 过程结构" href="../w3cnote/verilog-process-structure.html" >4.1 Verilog 过程结构</a></li>
	
		
	<li><a target="_top" data-id="22939" title="4.2 Verilog 过程赋值" href="../w3cnote/verilog-process-assign.html" >4.2 Verilog 过程赋值</a></li>
	
		
	<li><a target="_top" data-id="22941" title="4.3 Verilog 时序控制" href="../w3cnote/verilog-timing-control.html" >4.3 Verilog 时序控制</a></li>
	
		
	<li><a target="_top" data-id="22943" title="4.4 Verilog 语句块" href="../w3cnote/verilog-statements-block.html" >4.4 Verilog 语句块</a></li>
	
		
	<li><a target="_top" data-id="22948" title="4.5 Verilog 条件语句" href="../w3cnote/verilog-condition-statement.html" >4.5 Verilog 条件语句</a></li>
	
		
	<li><a target="_top" data-id="22950" title="4.6 Verilog 多路分支语句" href="../w3cnote/verilog-case.html" >4.6 Verilog 多路分支语句</a></li>
	
		
	<li><a target="_top" data-id="22951" title="4.7 Verilog 循环语句" href="../w3cnote/verilog-loop.html" >4.7 Verilog 循环语句</a></li>
	
		
	<li><a target="_top" data-id="22954" title="4.8 Verilog 过程连续赋值" href="../w3cnote/verilog-deassign.html" >4.8 Verilog 过程连续赋值</a></li>
	
		
	<li><a target="_top" data-id="22966" title="5.1 Verilog 模块与端口" href="../w3cnote/verilog-module-port.html" >5.1 Verilog 模块与端口</a></li>
	
		
	<li><a target="_top" data-id="22969" title="5.2 Verilog 模块例化" href="../w3cnote/verilog-generate.html" >5.2 Verilog 模块例化</a></li>
	
		
	<li><a target="_top" data-id="22972" title="5.3 Verilog 带参数例化" href="../w3cnote/verilog-defparam.html" >5.3 Verilog 带参数例化</a></li>
	
		
	<li><a target="_top" data-id="22975" title="6.1 Verilog 函数" href="../w3cnote/verilog-function.html" >6.1 Verilog 函数</a></li>
	
		
	<li><a target="_top" data-id="22982" title="6.2 Verilog 任务" href="../w3cnote/verilog-task.html" >6.2 Verilog 任务</a></li>
	
		
	<li><a target="_top" data-id="22990" title="6.3 Verilog 状态机" href="../w3cnote/verilog-fsm.html" >6.3 Verilog 状态机</a></li>
	
		
	<li><a target="_top" data-id="22999" title="6.4 Verilog 竞争与冒险" href="../w3cnote/verilog-competition-hazard.html" >6.4 Verilog 竞争与冒险</a></li>
	
		
	<li><a target="_top" data-id="23008" title="6.5 Verilog 避免 Latch" href="../w3cnote/verilog-latch.html" >6.5 Verilog 避免 Latch</a></li>
	
		
	<li><a target="_top" data-id="23011" title="6.6 Verilog 仿真激励" href="../w3cnote/verilog-testbench.html" >6.6 Verilog 仿真激励</a></li>
	
		
	<li><a target="_top" data-id="23015" title="6.7 Verilog 流水线" href="../w3cnote/verilog-pipeline-design.html" >6.7 Verilog 流水线</a></li>
	
		
	<li><a target="_top" data-id="23021" title="7.1 Verilog 除法器设计" href="../w3cnote/verilog-dividend.html" >7.1 Verilog 除法器设计</a></li>
	
		
	<li><a target="_top" data-id="23222" title="7.2 Verilog 并行 FIR 滤波器设计" href="../w3cnote/verilog-fir.html" >7.2 Verilog 并行 FIR 滤波器设计</a></li>
	
		
	<li><a target="_top" data-id="23230" title="7.3 Verilog 串行 FIR 滤波器设计" href="../w3cnote/verilog-serial-fir.html" >7.3 Verilog 串行 FIR 滤波器设计</a></li>
	
		
	<li><a target="_top" data-id="23236" title="7.4 Verilog CIC 滤波器设计" href="../w3cnote/verilog-cic.html" >7.4 Verilog CIC 滤波器设计</a></li>
	
		
	<li><a target="_top" data-id="23260" title="7.5 Verilog FFT 设计" href="../w3cnote/verilog-fft.html" >7.5 Verilog FFT 设计</a></li>
	
		
	<li><a target="_top" data-id="23309" title="7.6 Verilog DDS 设计" href="../w3cnote/verilog-dds.html" >7.6 Verilog DDS 设计</a></li>
	
		
	<li><a target="_top" data-id="23281" title="8.1 Verilog 数值转换" href="../w3cnote/verilog-numerical-conversion.html" >8.1 Verilog 数值转换</a></li>
	
	<li><a target="_top" title="Verilog 教程高级篇" href="../w3cnote/verilog2-tutorial.html" >Verilog 教程高级篇</a></li></ul></div>	</div>
</div>


<!-- 底部 -->
<div id="footer" class="mar-t50">
   <div class="runoob-block">
    <div class="runoob cf">
     <dl>
      <dt>
       在线实例
      </dt>
      <dd>
       &middot;<a target="_blank" href="../html/html-examples.html">HTML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../css/css-examples.html">CSS 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../js/js-examples.html">JavaScript 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../ajx/ajax-examples.html">Ajax 实例</a>
      </dd>
       <dd>
       &middot;<a target="_blank" href="../jquery/jquery-examples.html">jQuery 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../xml/xml-examples.html">XML 实例</a>
      </dd>
      <dd>
       &middot;<a target="_blank" href="../java/java-examples.html">Java 实例</a>
      </dd>
     
     </dl>
     <dl>
      <dt>
      字符集&工具
      </dt>
      <dd>
       &middot; <a target="_blank" href="../charsets/html-charsets.html">HTML 字符集设置</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-ascii.html">HTML ASCII 字符集</a>
      </dd>
     <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6939/">JS 混淆/加密</a>
      </dd> 
      <dd>
       &middot; <a target="_blank" href="https://c.runoob.com/front-end/6232/">PNG/JPEG 图片压缩</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="../tags/html-colorpicker.html">HTML 拾色器</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/53">JSON 格式化工具</a>
      </dd>
      <dd>
       &middot; <a target="_blank" href="..//c.runoob.com/front-end/6680/">随机数生成器</a>
      </dd>
     </dl>
     <dl>
      <dt>
       最新更新
      </dt>
                   <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imread.html" title="Matplotlib imread() 方法">Matplotlib imre...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imsave.html" title="Matplotlib imsave() 方法">Matplotlib imsa...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-imshow.html" title="Matplotlib imshow() 方法">Matplotlib imsh...</a>
      </dd>
              <dd>
       &middot;
      <a href="../matplotlib/matplotlib-hist.html" title="Matplotlib 直方图">Matplotlib 直方图</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-func-object.html" title="Python object() 函数">Python object()...</a>
      </dd>
              <dd>
       &middot;
      <a href="../python3/python-ai-draw.html" title="Python AI 绘画">Python AI 绘画</a>
      </dd>
              <dd>
       &middot;
      <a href="../w3cnote/cursor-editor.html" title="神辅助 Cursor 编辑器，加入 GPT-4 让编码更轻松！">神辅助 Cursor ...</a>
      </dd>
             </dl>
     <dl>
      <dt>
       站点信息
      </dt>
      <dd>
       &middot;
       <a target="_blank" href="mailto:admin@runoob.com" rel="external nofollow">意见反馈</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../disclaimer">免责声明</a>
       </dd>
      <dd>
       &middot;
       <a target="_blank" href="../aboutus">关于我们</a>
       </dd>
      <dd>
       &middot;
      <a target="_blank" href="../archives">文章归档</a>
      </dd>
    
     </dl>
    
     <div class="search-share">
      <div class="app-download">
        <div>
         <strong>关注微信</strong>
        </div>
      </div>
      <div class="share">
      <img width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png" />
       </div>
     </div>
     
    </div>
   </div>
   <div class="w-1000 copyright">
     Copyright &copy; 2013-2023    <strong><a href="../" target="_blank">菜鸟教程</a></strong>&nbsp;
    <strong><a href="../" target="_blank">runoob.com</a></strong> All Rights Reserved. 备案号：<a target="_blank" rel="nofollow" href="https://beian.miit.gov.cn/">闽ICP备15012807号-1</a>
   </div>
  </div>
  <div class="fixed-btn">
    <a class="go-top" href="javascript:void(0)" title="返回顶部"> <i class="fa fa-angle-up"></i></a>
    <a class="qrcode"  href="javascript:void(0)" title="关注我们"><i class="fa fa-qrcode"></i></a>
    <a class="writer" style="display:none" href="javascript:void(0)"   title="标记/收藏"><i class="fa fa-star" aria-hidden="true"></i></a>
    <!-- qrcode modal -->
    <div id="bottom-qrcode" class="modal panel-modal hide fade in">
      <h4>微信关注</h4>
      <div class="panel-body"><img alt="微信关注" width="128" height="128" src="/wp-content/themes/runoob/assets/images/qrcode.png"></div> 
    </div>
  </div>

 <div style="display:none;">
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-84264393-2"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'UA-84264393-2');
</script>
<script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?3eec0b7da6548cf07db3bc477ea905ee";
  var s = document.getElementsByTagName("script")[0]; 
  s.parentNode.insertBefore(hm, s);
})();
</script>

</div>
<script>
window.jsui={
    www: 'https://www.runoob.com',
    uri: 'https://www.runoob.com/wp-content/themes/runoob'
};
</script>

<script src=""></script>
<script src=""></script>

</body>
</html>